home *** CD-ROM | disk | FTP | other *** search
- ╒═══════════════════════════════╕
- │ W E L C O M E │
- │ To the VGA Trainer Program │ │
- │ By │ │
- │ DENTHOR of ASPHYXIA │ │ │
- │ (updated by Snowman) │ │ │
- ╘═══════════════════════════════╛ │ │
- ────────────────────────────────┘ │
- ────────────────────────────────┘
-
- --==[ PART 10 ]==--
-
- Note: This is Snowman here. This is tutorial 10, and 10 is a pretty
- important number. For normal humans, this is first number greater
- than 0 that needs two characters to represent it. (of course for us
- REAL programmers, its 16, but you can't expect your parents to
- understand that sort of thing).
-
- Anyway, I have decided to take a different approach to the converting
- of these tutorials. Denthor and I have built up a friendly line of
- communication. As such, I am going to start putting in my two cents
- wherever I feel like it (pointing out as many of Denthor's errors as
- I possibly can, be they real or imagined). Unless Denthor decides to
- turn around and re-edit all of these tutorials, there is no way that
- that he can respond to anything I have to say, so its a win-win
- situation. muhahahaaa!
-
- I just checked and there has been about 210k of source code converted
- from Pascal to C++. 210k! Do you know what all of that typing can
- do to someone? Have you any idea how many times I've stayed up until
- 5 in the morning working on one of these things? Well, I'm sick of
- just letting Denthor have all the glory. That's right. As of
- tutorial part 10, I am now the "deviant convertor", and will do my
- best to make this series as 'interesting' as I possibly can.
-
- -Christopher (Snowman) G. Mann / HORNET r3cgm@dax.cc.uakron.edu
-
- [BTW: Anything in brackets has been added by Snowman]
- <BTW: Anything in those <> thingies is made-up Denthor stuff>
-
- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- ■ Introduction
-
- Wow! The trainer has finally reached part 10! This will also be the
- first part introduced simultaneously to local BBS's and the INTERNET at
- the same time! Yes folks, I put up a copy of previous tutorials onto
- various ftp sites, and awaited the flames saying that the net.gurus
- already knew this stuff, and why was I wasting disk space! The flames
- did not appear (well, except for one), and I got some messages saying
- keep it up, so from now on I will upload all future trainers to ftp
- sites too (wasp.eng.ufl.edu , cs.uwp.edu etc.). I will also leave a
- notice in the USENET groups comp.lang.pascal and comp.sys.ibm.pc.demos
- when a new part is finished (Until enough people say stop ;-))
-
- I can also be reached at my new E-Mail address,
- smith9@batis.bis.und.ac.za
-
- Well, this tutorial is on Chain-4. When asked to do a trainer on
- Chain-4, I felt that I would be walking on much travelled ground (I have
- seen numerous trainers on the subject), but the people who asked me said
- that they hadn't seen any, so could I do one anyway? Who am I to say no?
-
- [I happen to know personally that Denthor didn't get any mail asking him
- to do a Chain-4 tutor. He's just trying to show off.]
-
- The sample program attached isn't that great, but I am sure that all you
- people out there can immediately see the potential that Chain-4 holds.
-
- [As far as the code goes, I must ask: // where are these? ]
-
- If you would like to contact me, or the team, there are many ways you
- can do it : 1) Write a message to Grant Smith/Denthor/Asphyxia in private mail
- on the ASPHYXIA BBS.
- 2) Write to Denthor, EzE or Goth on Connectix.
- 3) Write to : Grant Smith
- P.O.Box 270 Kloof
- 3640
- Natal
- South Africa
- 4) Call me (Grant Smith) at (031) 73 2129 (leave a message if you
- call during varsity). Call +27-31-73-2129 if you call
- from outside South Africa. (It's YOUR phone bill ;-))
- 5) Write to smith9@batis.bis.und.ac.za in E-Mail.
-
- NB : If you are a representative of a company or BBS, and want ASPHYXIA
- to do you a demo, leave mail to me; we can discuss it.
- NNB : If you have done/attempted a demo, SEND IT TO ME! We are feeling
- quite lonely and want to meet/help out/exchange code with other demo
- groups. What do you have to lose? Leave a message here and we can work
- out how to transfer it. We really want to hear from you!
-
-
-
- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- ■ What is Chain-4?
-
- You people out there all have at least 256k vga cards. Most of you have
- 512k vga cards, and some have 1MB vga cards. But what you see on your
- screen, as discussed in previous trainers, is 64k of data! What happened
- to the other 192k??? Chain-4 is a method of using all 256k at one time.
-
- [But is it difficult to use the other 192k?]
-
- Heck no, its simple! 1 screen = 64k. 64k * 4 = 256k. Therefore, chain-4
- allows you to write to four screens, while displaying one of them. You can
- then move around these four screens to see the data on them. Think of the
- Chain-4 screen as a big canvas. The viewport, the bit you see out of, is a
- smaller rectangle which can be anywhere over the bigger canvas.
-
- +----------------------------+ Chain-4 screen
- | +--+ |
- | | | <- Viewport |
- | +--+ |
- | |
- +----------------------------+
-
- [But Denthor, if I can see 1/4th of the screen at one time, isn't your
- diagram a little out of scale?]
-
- <Well... I guess so, but that's not the point. I'm just trying to show
- everyone how they should _think_ about a chain 4 screen.>
-
- [But how can they understand if you give them faulty diagrams?]
-
- <Oh, shut up already!>
-
- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- ■ The size of the chain-4 screen
-
- The Chain-4 screen, can be any size that adds up to 4 screens.
-
- For example, it can be 4 screens across and one screen down, or one
- screen across and 4 screens down, or two screens across and two screens
- down, and any size in between.
-
- [Er... Denthor, you already listed the 3 possible combinations of
- a chain-4 layout: 4 across and 1 down, 4 down and 1 across, and 2
- across AND down. Are you saying we could have something like 1.5
- screens across and 2.5 down? I mean, come on!, you're confusing me.]
-
- <Actually, I just added that "any size in between" to confuse the
- reader. My evil plan has worked! muhaaha...>
-
- In the sample program, the size is a constant. The size * 8 is how many
- pixels across there are on the chain-4 screen, ie
- Size = 40 = 320 pixels across = 1 screen across, 4 screens down
- Size = 80 = 640 pixels across = 2 screens across, 2 screens down
- etc.
-
- We need to know the size of the screen for almost all dealings with the
- Chain-4 screen, for obvious reasons.
-
-
- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- ■ Layout of the chain-4 screen, and accessing it
-
- If you will remember all the way back to Part 1 of this series, I
- explained that the memory layout of the MCGA screen is linear. Ie, the
- top left hand pixel was pixel zero, the one to the right of it was
- number one, the next one was number two etc. With Chain-4, things are
- very different.
-
- [Hey, shouldn't you also have said something like "After you get to
- the right of the screen and go back to the left (next line) the computer
- thinks of that as pixel 321 and not line 2, pixel 1"?]
-
- <Well, I just _assumed_ that if you got this far in the series, you'd
- understand the basic layout of video memory!>
-
- [Jeesh, it was just a question, don't overreact.]
-
- <What am I supposed to do, just happily explain code while you are
- constantly making up all of these things that I'm saying? Besides, all
- of these comments are detracting from the reader's understanding of
- the code.>
-
- [Denthor, you forget. You no longer have any power in here. This is
- MY domain now. Just think of me as the Borg.]
-
- Chain-4 gets the 4 screens and chains them together (hence the name :)).
- Each screen has a different plane value, and must be accessed
- differently. The reason for this is that a segment of memory is only 64k
- big, so that we could not fit the entire Chain-4 screen into one
- segment.
-
- All Chain-4 screens are accessed from $a000, just like in MCGA mode.
- What we do is, before we write to the screen, find out what plane we are
- writing to, set that plane, then plot the pixel. Here is how we find out
- how far in to plot the pixel and what plane it is on :
-
- Instead of the linear model of MCGA mode, ie :
- ┌──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┐
- │00│01│02│03│04│05│06│07│08│09│10│11│ ...
-
- Each plane of the Chain-4 screen accesses the memory in this way :
-
- Plane 0 :
- ┌──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┐
- │00│ │ │ │01│ │ │ │02│ │ │ │ ...
-
- Plane 1 :
- ┌──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┐
- │ │00│ │ │ │01│ │ │ │02│ │ │ ...
-
- Plane 2 :
- ┌──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┐
- │ │ │00│ │ │ │01│ │ │ │02│ │ ...
-
- Plane 3 :
- ┌──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┐
- │ │ │ │00│ │ │ │01│ │ │ │02│ ...
-
- In this way, by choosing the right plane to write to, we can access all
- of the 256k of memory available to us. The plane that we write to can
- easily be found by the simple calculation of x mod 4, and the x
- coordinate is also found by x div 4. We work out our y by multiplying
- it by the size of our chain-4 screen.
-
- [Could you be a little MORE cryptic? I had to read this last paragraph
- three times before I got what you were saying.]
-
- <Hey, I already know this stuff. Why should I make it clear for the
- reader? ... oh wait a minute, this is a tutorial! My mistake, won't
- happen again.>
-
- NOTE : It is possible to write to all four planes at once by setting the
- correct port values.
-
- [Any chance you could share this knowledge with the reader?]
-
- <No can do, its an Asphyxia secret.>
-
- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- ■ Uses of Chain-4
-
- The uses of Chain-4 are many. One could write data to one screen, then
- flip to it (the move_to command is almost instantaneous). This means
- that 64k of memory does not need to be set aside for a virtual screen,
- you are using the vga cards memory instead!
-
- Scrolling is much easier to code for in Chain-4 mode.
-
- [Scrollers are for lamers.]
-
- <I don't mean text scrollers you idiot! I mean for other things, like
- moving around a picture on the screen, etc.>
-
- [Hey, watch your attitude with me or I'll put bugs in the pascal source
- and say you did it.]
-
- <You wouldn't!>
-
- [I would.]
-
- <OK, I'm sorry.>
-
- <[shaking hands]>
-
- It is possible to "tweak" the mode into other resolutions. In our demo,
- our vectors were in 320x240 mode, and our dot vectors were in 320x400
- mode.
-
- The main disadvantage of chain-4 as I see it is the plane swapping,
- which can be slow. With a bit of clever coding however, these can be
- kept down to a minimum.
-
- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- ■ The sample programs
-
- The first sample program is GFX.PAS. This is a until in which I have
- placed most of our routines from previous tuts. All the procedures and
- variables you can see under the INTERFACE section can be used in any
- program with GFX in the USES clause. In other words, I could do this :
-
- USES GFX,crt;
-
- BEGIN
- Setupvirtual;
- cls (vaddr,0);
- Shutdown;
- END.
-
- [Its about time you started putting these functions in an external
- file. Hell, I did it back in tut7. Do you know how much redundant
- code you made the pascal'ers go through?]
-
- <Well, call it a quirk of mine, but I _really_ like to cut and paste.>
-
- [er...]
-
- This program would compile perfectly. What I suggest you do is this :
- Rename the file to a name that suites you (eg your group name), change
- the first line of the unit to that name, then add all useful procedures
- etc. to the unit. Make it grow :-).
-
- The second file is the sample program (note the USES GFX,crt; up near
- the top!). The program is easy to understand and is documented.
-
- [hahaha.... "documented"? I've seen business cards with more
- documentation than your programs.]
-
- <Hey, without these programs to convert, you wouldn't have _anything_
- useful to contribute!>
-
- [Now that was just mean! I make one comment about your documentation
- and you make fun of me like that. Can't we all just get along?]
-
- <I'm sorry Snowman. Sometimes my temper just gets away from me.>
-
- <[shaking hands]>
-
- The bit that I want to draw your attention to is the constant, BIT. Because
- I am distributing this file to many places in text form, not binary form, I
- could not just add a .CEL file with the program. So what I did was write
- some text in one color then saved it as a .CEL . I then wrote a ten line
- program that did the following : Moving from left to right, it counted how
- many pixels were of color zero, then saved the byte value to an array. When
- it came across color one, is counted for how long that went on then saved
- the byte value and saved it to an array and so on. When it was finished, I
- converted the array into a text file in the CONST format. Not too cunning,
- but I thought I had better explain it ;-)
-
- [Actually, that was a pretty good idea.]
-
- <Thank you.>
-
- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- ■ In closing
-
- There are other documents and sample programs available on Chain-4 and
- it's like : Try XLIB for one...
-
- Finally! Some BBS's have joined my BBS list! (Okay, only two new ones,
- but it's a start ;-)) All you international BBS's! If you will regularly
- download the tuts from an FTP site, give me your names!
-
- I own a car. The car's name is Bob. A few days ago, Bob was in an
- accident, and now has major damage to his front. Knowing insurance, I
- probably won't get much, probably nothing (the other guy wasn't insured,
- and I am only 18 :( ). I will probably have to find work in order to pay
- for my repairs. The point to this meandering is this : I am upset, so if
- you think you are getting a quote, you can just forget it.
-
- Oh, well. Life goes on!
-
- [Your car's name is Bob? Do you name your silverware too?]
-
- <Hey, a car has feelings just like anyone else. Don't make fun of Bob,
- he's very sensitive.>
-
- [Won't happen again.]
-
- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
- [This is Snowman...]
-
- <...and this is Denthor...>
-
- [<...and WE, ARE, OUTTA HERE! >]
-
- These fine BBS's carry the ASPHYXIA DEMO TRAINER SERIES : (alphabetical)
-
- ╔══════════════════════════╦════════════════╦═════╦═══╦════╦════╗
- ║BBS Name ║Telephone No. ║Open ║Msg║File║Past║
- ╠══════════════════════════╬════════════════╬═════╬═══╬════╬════╣
- ║ASPHYXIA BBS #1 ║(031) 765-5312 ║ALL ║ * ║ * ║ * ║
- ║ASPHYXIA BBS #2 ║(031) 765-6293 ║ALL ║ * ║ * ║ * ║
- ║Connectix BBS ║(031) 266-9992 ║ALL ║ ║ * ║ * ║
- ║POP! ║(012) 661-1257 ║ALL ║ ║ * ║ * ║
- ║Pure Surf BBS ║(031) 561-5943 ║A/H ║ ║ * ║ * ║
- ╚══════════════════════════╩════════════════╩═════╩═══╩════╩════╝
-
- For international users : If you live outside the Republic of South
- Africa, do the following : Dial +27, dont dial the first 0, but dial
- the rest of the number. Eg, for the ASPHYXIA BBS : +27-31-765-5312
-
- Open = Open at all times or only A/H
- Msg = Available in message base
- File = Available in file base
- Past = Previous Parts available
-
-